﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;

namespace Mvc4Demo.Core
{
    public class Mvc4DemoSettings : ConfigurationSection
    {
        public static Mvc4DemoSettings Settings { get; private set; }

        static Mvc4DemoSettings()
        {
            Settings = ConfigurationManager.GetSection("Mvc4DemoSettings") as Mvc4DemoSettings;
        }


        [ConfigurationProperty("ConnectionString", IsRequired = true)]
        [StringValidator(InvalidCharacters = "  ~!@#$%^&*()[]{}/;’\"|\\", MinLength = 1, MaxLength = 256)]
        public string ConnectionString
        {
            get { return (string) this["ConnectionString"]; }
            set { this["ConnectionString"] = value; }
        }

        [ConfigurationProperty("frontPagePostCount", DefaultValue = 20, IsRequired = false)]
        [IntegerValidator(MinValue = 1, MaxValue = 100)]
        public int FrontPagePostCount
        {
            get { return (int)this["frontPagePostCount"]; }
            set { this["frontPagePostCount"] = value; }
        }

    }
}